package com.project.controller;

import com.project.result.Result;
import com.project.service.ApprovalStepsService;
import com.project.vo.ApprovalStepDetailVO;
import com.project.vo.ApprovalStepListVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/approval-steps")
@Slf4j
public class ApprovalStepsController {
    @Autowired
    private ApprovalStepsService approvalStepsService;

    /**
     * 根据ID查询审批步骤记录
     * @param id 审批步骤 id
     * @return
     */
    @GetMapping("/{id}")
    public Result<ApprovalStepDetailVO> getByStepId(@PathVariable Integer id){
        log.info("根据ID查询审批步骤记录：{}",id);
        ApprovalStepDetailVO approvalStepDetailVO= approvalStepsService.getByStepId(id);

        return Result.success(approvalStepDetailVO);

    }

    /**
     * 根据审批实例ID获取步骤列表
     * @param approvalId 审批实例ID
     * @return
     */
    @GetMapping("/by-approval/{approvalId}")
    public Result getStepListByApprovalId(@PathVariable Integer approvalId){
        log.info("根据审批实例ID获取步骤列表：{}",approvalId);
        List<ApprovalStepListVO> list=approvalStepsService.getListByApprovalId(approvalId);
        return Result.success(list);
    }
}
